use "$replication\data\for_summary.dta", clear





global sumvars "pc01_vd_power_all pc01_vd_dirt_road  pc01_vd_tar_road  pc01_pca_tot_p pc01_vd_area pc01_pca_p_sc_share pc01_pca_p_lit_share primary_school"
global sumvar_count=wordcount("$sumvars")

// prepare a matrix
matrix results = J(${sumvar_count},4,.)
matrix rownames results = $sumvars


gen year_all=0

local i=-1
foreach int in elecXroad all {
	sum  in_`int'_sample if in_`int'_sample
	local N_`int'=r(N)
	
	disp "`int'"
	local i=`i'+2
	local j=0
	foreach var in $sumvars {
		local j=`j'+1
		local ip1=`i'+1
		local ip2=`i'+2
		sum `var' if in_`int'_sample
		matrix results[`j',`i'] = r(mean)
		matrix results[`j',`ip1'] = r(sd)
	}
	
}


label var pc01_vd_area "Area (hectares)"
label var primary_school "Primary school"
label var pc01_vd_power_all "Electrified"
label var pc01_vd_dirt_road "Dirt road" 
label var pc01_vd_tar_road "Tar road"
label var pc01_pca_tot_p "Population"
label var pc01_pca_p_sc_share "Scheduled caste (share)"
label var pc01_pca_p_lit_share "Literate (share)"

matrix list results